package com.modouyu.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * ${DESCRIPTION}
 *
 * @author yangcb
 * @email mudouyu@aliyun.com
 * @create 2018-04-11 18:08
 **/
@Service
public class HelloService {

    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "helloCallback")
    public String hello() {
        return restTemplate.getForEntity("http://spring-cloud-provider:8081/hello", String.class).getBody();
    }

    public String helloCallback() {
        return "error";
    }


}
